﻿@model IEnumerable<Stardust.Models.ProveedorBean>

<h2>Buscar Proveedor</h2>




@using (Html.BeginForm("Buscar", "Proveedor", FormMethod.Post, new { @class = "form" }))
{
    @Html.ValidationSummary(false)
    <fieldset>
        <div class = "widget" >
            <div class = "title"><h6>Buscar Proveedor</h6></div>

            <div class="formRow">
                <label>Razon Social</label>
                <div class = "formRight" ><input type = "text" id = "razonSocial" name = "razonSocial" /></div>
                <div class = "clear" ></div>
            </div>

            <div class="formRow">
                <label>Contacto</label>
                <div class = "formRight" ><input type = "text" id = "contacto" name = "contacto" /></div>
                <div class = "clear" ></div>
            </div>
        </div>
    </fieldset>
    <p>
        <input type="submit" value="Buscar" class = "redB" />
    </p>
}

<p></p>
<div>
    @Html.ActionLink("Regresar", "Buscar", "Proveedor") | @Html.ActionLink("Lista Proveedores", "Index", "Proveedor")
</div>

<p></p><p></p>

@if (ViewBag.estado != 0)
{ 
<div class="wrapper">
    <div class="widget">
      <div class="title"><h6>Lista de Proveedores</h6></div>
      <div class="dataTables_wrapper">
        <table cellpadding = "0" cellspacing = "0" width = "100%" class = "display dTable">
        <thead>
        <tr>
            <th class="ui-state-default" rowspan="1" colspan="1" style="width:160px;">
                <div class="DataTables_sort_wrapper">
                Razon Social
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>
            <th class="ui-state-default" rowspan="1" colspan="1" style="width:160px;" >
                <div class="DataTables_sort_wrapper">
                Dirección
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>
               <th class="ui-state-default" rowspan="1" colspan="1" style="width:120px;" >
                <div class="DataTables_sort_wrapper">
                teléfono
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>
               
             <th class="ui-state-default" rowspan="1" colspan="1" style="width:120px;" >
                <div class="DataTables_sort_wrapper">
                Estado
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>
            <th class="ui-state-default" rowspan="1" colspan="1">

             </th>
        </tr>
    </thead>

    <tbody>
    @foreach (var item in Model)
    {
        <tr class="gradeA odd">
            <td>@Html.DisplayFor(modelItem => item.razonSocial)</td>
            <td>@Html.DisplayFor(modelItem => item.direccion)</td>
            <td>@Html.DisplayFor(modelItem => item.telefono)</td>
            
            <td>@Html.DisplayFor(modelItem => item.estado2)</td>
            <td>
                <a href="@Url.Action("ModificarProveedor", new { id = item.ID })"><img src="../../Content/images/icons/color/pencil.png", alt="Edit" />Editar </a> | 
                <a href="@Url.Action("DetallesProveedor", new { id = item.ID })"><img src="../../Content/images/icons/color/edit-column.png", alt="Details" />Detalles</a> |   
                
                @if (item.estado!=0)
                {
                    <a  id = @item.ID class = "eliminar" href=""><img src="../../Content/images/icons/color/cross.png", alt="Delete" />Borrar</a>  
                    <a href="@Url.Action("ListarProductos", new { id = item.ID })"><img src="../../Content/images/icons/color/notebook.png", alt="Delete" />Asignar Productos</a>   
                }
                    
            </td>
        </tr>
        
    }

     <div id="dialogEliminar" title="Desea Eliminar el Proveedor?">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
    El proveedor que UD. Elimine ya no podra ser recuperado</p>
    </div>


    </tbody>
</table>
      </div>
        
    </div>
    </div>
}

    
    <script type = "text/javascript">
        var idEliminar = 0;
        $(".eliminar").click(function () {
            //Jp++ GPL version xD
            $('#dialogEliminar').dialog('open');
            idEliminar = $(this).attr("id");
            return false;
        });

        $('#dialogEliminar').dialog({
            autoOpen: false,
            resizable: false,
            draggable: false,
            width: 300,
            modal: true,
            title: "!Confirmar Eliminacion de Proveedor",
            position: "center",
            buttons: {
                "Aceptar": function () {
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        url: "Delete/" + idEliminar,
                        success: function (data) {
                            oTable.fnDraw(false);
                            if (data.me == "") {
                                $(this).dialog("close");
                                location.reload();
                            }
                        }
                    });

                },
                "Cancelar": function () {
                    $(this).dialog("close");
                    return false;
                }
            }
        });

</script>
